package day0727API;

public class Test4 {
    public static void main(String[] args) {
        ClothShop bank=new ClothShop();
        Thread t1=new Thread(){
            public void run() {
            }
        };
        t1.start();


        Thread t2=new Thread(()-> {
        });
        t2.start();
    }

}


class ClothShop{
    public void choose() throws InterruptedException {//结算
        System.out.println(Thread.currentThread().getName()+"正在挑选衣服");
        Thread.sleep(2000);
        System.out.println(Thread.currentThread().getName()+"挑选完毕，准备试衣服");
    }
    Object  o=new Object();    //synchronized: 确保某线程执行此方法时，其他线程不能此方法
    public  synchronized void  tryCloth() throws InterruptedException {//取钱
        System.out.println(Thread.currentThread().getName()+"正在试衣服");
        Thread.sleep(2000);
        System.out.println(Thread.currentThread().getName()+"试衣服完毕，准备结账");
    }
    public void checkOut() throws InterruptedException {//结算
        System.out.println(Thread.currentThread().getName()+"正在结账");
        Thread.sleep(3000);
        System.out.println(Thread.currentThread().getName()+"结账完毕，离开....");
    }
}


